//
//  HXTablePlayerCell.m
//  ZCooking
//
//  Created by 韩旭 on 16/8/30.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "HXTablePlayerCell.h"
#import "HXPlayerCollectionCell.h"
#import "HX_Macro.h"
#import "HXCycleCellModel.h"
#import "UIImageView+WebCache.h"
@implementation HXTablePlayerCell
- (void)setUp {
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.minimumLineSpacing = 0;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
    _collectionView.backgroundColor = [UIColor whiteColor];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    _collectionView.showsHorizontalScrollIndicator = NO;
    _collectionView.bounces = NO;
    [self.contentView addSubview:_collectionView];
    [_collectionView registerNib:[UINib nibWithNibName:@"HXPlayerCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"reusePlayer"];
}
- (void)setArrDetail:(NSMutableArray *)arrDetail {
    _arrDetail = arrDetail;
}
- (void)setArrTitle:(NSMutableArray *)arrTitle {
    _arrTitle = arrTitle;
}
- (void)setArrToday:(NSMutableArray *)arrToday {
    _arrToday = arrToday;
    [_collectionView reloadData];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _arrToday.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HXPlayerCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reusePlayer" forIndexPath:indexPath];
    cell.labelName.text = self.arrDetail[indexPath.row];
    cell.detailLabel.text = self.arrTitle[indexPath.row];
    [cell.imageHead sd_setImageWithURL:[NSURL URLWithString:self.arrToday[indexPath.row]]];
    return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(self.bounds.size.width / 3, self.bounds.size.height);
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.collectionView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    self.item(indexPath.item);
}
@end
